<template>
    <div>
        机构名称 <input type="text" v-model="name" />
        特色服务
        <select v-model="fw">
            <option>请选择</option>
            <option v-for="item in ints" :value="item.jgts">{{ item.jgts }}</option>
        </select>
        <input type="button" value="查询" @click="show" />
        <table table table-border border="1">
            <thead>
                <tr style="color: blue">
                    <td><input type="checkbox" :value="quan" @change="xuan" /></td>
                    <td>机构名称</td>
                    <td>特色服务</td>
                    <td>分享</td>
                    <td>收藏</td>
                    <td>状态</td>
                    <td>更新人</td>
                    <td>最后的更新时间</td>
                    <td>操作</td>
                </tr>
            </thead>
            <tbody>
                <tr v-for="item in info">
                    <td><input type="checkbox" :value="fan" /></td>
                    <td>{{ item.jgName }}</td>
                    <td>{{ item.tsfw }}</td>
                    <td>{{ item.fx }}</td>
                    <td>{{ item.sc }}</td>
                    <td>{{ item.stary ? '已发布' : '未发布' }}</td>
                    <td>{{ item.gxr }}</td>
                    <td>{{ item.fbtime }}</td>
                    <td><input type="button" value="删除" @click="del(item.jgId)" /></td>
                </tr>
            </tbody>
        </table>
        共{{ page.count }}条,每页{{ page.size }}条,共{{ page.index }}/{{ page.pagecount }}页
        <input type="button" @click="pag(1)" value="首页" />
        <input type="button" @click="pag(2)" value="上一页" />
        <input type="button" @click="pag(6)" value="1" />
        <input type="button" @click="pag(7)" value="2" />
        <input type="button" @click="pag(8)" value="3" />
        <input type="button" @click="pag(9)" value="4" />
        <input type="button" @click="pag(3)" value="下一页" />
        <input type="button" @click="pag(4)" value="尾页" />
    </div>
</template>

<script setup lang="ts">
import { ref, onMounted } from 'vue'
import axios from 'axios'
onMounted(() => {
    show()
    ts()
})

const ints = ref([
    {
        tsid: 0,
        jgts: ''
    }
])
const info = ref([
    {
        jgId: 0,
        jgName: '',
        img: '',
        tsfw: '',
        yysj: '',
        addr: '',
        jgPhone: '',
        fbtime: '',
        jgxc: '',
        fx: '',
        sc: '',
        stary: true,
        gxr: '',
        isdel: true
    }
])
const page = {
    index: 1,
    size: 2,
    count: 0,
    pagecount: 0
}
const name = ref('')
const fw = ref('')
const show = () => {
    axios
        .get('https://localhost:7190/api/User/show', {
            params: {
                name: name.value,
                fw: fw.value,
                index: page.index,
                size: page.size,
                isdel: true
            }
        })
        .then(res => {
            console.log(res.data)
            info.value = res.data.date
            page.count = res.data.count
            page.pagecount = res.data.pagecount
        })
}
const ts = () => {
    axios.get('https://localhost:7190/api/User/tsshow').then(res => {
        ints.value = res.data
    })
}

const del = (id: any) => {
    if (!confirm('确认删除吗？')) {
    }
    axios.put('https://localhost:7190/api/User/delete?id=' + id).then(res => {
        if (res.data > 0) {
            alert('删除成功')
        } else {
            alert('删除失败')
        }
        show()
    })
}

const pag = (x: number) => {
    if (x == 1) {
        page.index = 1
    }
    if (x == 2) {
        page.index--
    }
    if (x == 3) {
        page.index++
    }
    if (x == 4) {
        page.index = page.pagecount
    }
    if (x == 6) {
        page.index = 1
    }
    if (x == 7) {
        page.index = 2
    }
    if (x == 8) {
        page.index = 3
    }
    if (x == 9) {
        page.index = 4
    }
    show()
}

const quan = true
const fan = false

const xuan = () => {}
</script>

<style scoped></style>
